import { Fight } from "../entity/fight";
import { Application } from "pinus";
 

export class PushService{

    public static ins() : PushService{
        if (PushService._ins == null){
            PushService._ins = new PushService(null);
        }
        return PushService._ins;
    }

    _app:Application;
  
    constructor(app:Application){
        if(app){
            this._app=app;
        }
        if (PushService._ins == null){
            PushService._ins =this;
        }
    }

    private static _ins = null;

    public async pushToOne (route,channelName, uid,msg) {
        let channel = this._app.channelService.getChannel(channelName);
        if (!channel) return;
         let member = channel.getMember(uid);
        if (!member) return;
    
         await this._app.channelService.pushMessageByUids(route, msg, [{uid: uid, sid: member.sid}]);
      }
    
 
 
   
}